<?php
class Nadeb_Form_Objects_Input
{
	protected $param;
	protected $label;
	
	protected $inputTag;
	protected $tag = "";
	
	protected function set_instance($_param)
	{
		$this->param = $_param;
		unset($this->param["rules"]);
		
		if( isset($_param["label"]) )
		{
			$this->label = $_param["label"];
			unset($this->param["label"]);
		}
	}
	
	public function create_object()
	{
		/*
		 * input TAG
		 */
		$this->inputTag = "<input";
		foreach($this->param as $key => $value)
		{
			if( $key == "name" || $key == "value")
				$this->inputTag .= ' ' . $key . '="' . $value . '"';
			else
				$this->inputTag .= ' ' . $key . '="' . strtolower($value) . '"';
		}
		$this->inputTag .= "/>";
		
		/*
		 * dt TAG
		 */
		if( $this->label )
		{
		$this->tag .= "
		<dt id=\"{$this->param["id"]}-label\">
			<label for=\"".strtolower($this->param["name"])."\" class=\"{$this->param["name"]}-label\">{$this->label}</label>
		</dt>";
		}

		
		/*
		 * dd TAG
		 */
		if( $this->param["type"] == "Hidden" )
		{
			$this->tag .= "\n\t\t$this->inputTag";
		}
		else
		{
			$this->tag .= "
		<dd id=\"{$this->param["id"]}-object\">
			$this->inputTag
		</dd>";
		}
	}
	
	public function get_xhtml()
	{
		return $this->tag;
	}
}
